﻿@model IEnumerable<GroupEntity>
@{
    Layout = "manage-2cols";

    Html.ViewContext.RouteData.Values["CurrentNavigationId"] = 13900190;

    GroupEntity group = ViewData.Get<GroupEntity>("group", null);
    bool canSetManager = new Authorizer().Group_SetManager(group);
}
<div class="tn-box tn-widget tn-widget-content tn-corner-all spb-group-members">
    <div class="tn-box-content tn-widget-content tn-corner-all">
        <div class="tn-main-heading tn-border-gray tn-border-bottom">
            <h2>
                子店铺管理
            </h2>
        </div>
        <div class="tn-tabs">
            <ul class="tn-tabs-nav tn-border-gray tn-border-bottom tn-helper-clearfix">
                <li class="tn-widget-content tn-border-gray tn-border-trl">
                    <a href="@SiteUrls.Instance().ManageMemberApplies(group.GroupKey)">
                        申请处理
                    </a>
                </li>
                <li class="tn-widget-content tn-border-gray tn-border-trl">
                    <a href="@SiteUrls.Instance().ManageMembers(group.GroupKey)">
                        成员管理
                    </a>
                </li>
                <li class="tn-widget-content tn-border-gray tn-border-trl tn-tabs-selected">
                    <a href="@SiteUrls.Instance().ManageChildGroups(group.GroupKey)">
                        子店铺管理
                    </a>
                </li>
            </ul>
            <div class="tn-tabs-panel">
                <div class="tn-list-header">
                    <div class="tn-toolbar-area tn-helper-clearfix">
                        
                    </div>
                </div>
                @if (Model != null && Model.Count() > 0)
                {
                    <form action="#" method="post" id="Form-BatchSet">
                        <table class="tn-table-grid">
                            <tbody>
                            
                                <tr class="tn-table-grid-header">
                                    <td class="tn-border-bottom tn-border-gray tn-text-note"> &nbsp;</td>
                                    <td class="tn-border-bottom tn-border-gray tn-text-note">
                                        名称
                                    </td>
                                    <td class="tn-border-bottom tn-border-gray tn-text-note">
                                        会员数量
                                    </td>
                                        <td class="tn-border-bottom tn-border-gray tn-text-note">
                                            创建时间
                                        </td>
                                    <td class="tn-border-bottom tn-border-gray tn-text-note">
                                        操作
                                    </td>
                                </tr>
                                @foreach (var item in Model)
                                {
                                    <tr class="tn-table-grid-row" id="ManageChildGroups_@(item.GroupId)">
                                        <td class="tn-border-bottom tn-border-gray tn-width-check">
                                            &nbsp;
                                        </td>
                                        <td class="tn-border-bottom tn-border-gray tn-width-user-name tn-nowrap">
                                            <a href="@SiteUrls.Instance().ManageMembers(group.GroupKey,item.GroupKey)" title="@Html.ShowUserDisplayName(item.GroupId)" target="_self">@item.GroupName</a>
                                        </td>
                                        <td class="tn-border-bottom tn-border-gray tn-width-auto">
                                            <a href="@SiteUrls.Instance().ManageMembers(group.GroupKey, item.GroupKey)" target="_self">@item.MemberCount</a></td>

                                            <td class="tn-border-bottom tn-border-gray tn-width-action2 tn-nowrap">
                                                @item.DateCreated.ToFriendlyDate()
                                            </td>
                                        <td class="tn-border-bottom tn-border-gray tn-width-action2 tn-nowrap">
                                            @Html.Link("限制设置", SiteUrls.Instance()._ChangeGroupLimit(GroupIdToGroupKeyDictionary.GetGroupKey(item.GroupId), Request.RawUrl), "限制设置", htmlAttributes: new { plugin = "dialog" })
                                            @Html.Link("改密码", SiteUrls.Instance()._ChangeGroupPwd(GroupIdToGroupKeyDictionary.GetGroupKey(item.GroupId), Request.RawUrl), "改密码", htmlAttributes: new { plugin = "dialog" })
                                          @Html.LinkButton("", SiteUrls.Instance().DeleteGroupLimt(item.GroupId), iconType: IconTypes.Cross, htmlAttributes: new { id = "BatchRemoveMember-" + item.GroupId, title = "移除子商户" })
                                        </td>
                                    </tr>
                                }
                            </tbody>
                        </table>
                        <div class="tn-pagination">

                        </div>
                    </form>
                }
                else
                {
                    <div class="tn-no-data">
                        搜索不到子商户
                    </div>
                }
            </div>
        </div>
    </div>
</div>
<script language="javascript" type="text/javascript">

    $(document).ready(function () {
        //全选按钮
        $("input#memberIds-checkAll").click(function () {
            checkAll(this, "GroupId");
        });
        //设置管理员
        $("a[id^='IsManager-']").click(function () {
            var url = this.href;
            $.post(url, function (data) {
                art.dialog.tips(data.MessageContent, 1.5, data.MessageType,
                function () {
                    window.location.reload(true);
                });
            });
            return false;
        });

        //删除
        $("a[id^='BatchRemoveMember-']").click(function (e) {
            e.preventDefault();
            url = $(this).attr("href");
            art.dialog.confirm('您确认要删除这些商户吗？', function () {
                $.post(url, $("form#Form-BatchSet").serialize(), function (data) {
                    art.dialog.tips("删除成功", 1.5, data.MessageType,
                    function () {
                        window.location.reload(true);
                    });
                });
            });
        });
    });

</script>
